<#include "../common/common.html"/>
<@layout>
<script type="text/javascript">
    var url,ids = [];
    /**
     * 编辑选中的用户信息
     */
    function editModel() {
        $('#myform').form('clear');

        var row = $('#dt-grids').datagrid('getSelected');
        if (row) {
            $('#dlg').dialog('setTitle', '修改用户密码').dialog('open');
            $('#myform').form('load', row);
            $('#password').attr("value","");
            url = '${ctx}/newPassword/update/' + row.id;
        } else {
            $.messager.show({
                title : '提示',
                msg : '请先选择用户，再进行修改。',
                timeout:2000
            });
        }
    }
    /**
     * 保存新增的用户数据，并对登录密码进行校验
     */
    function saveModel() {
        var row = $('#dt-grids').datagrid('getSelected');

        $('#myform').form('submit', {
            url : '${ctx}/newPassword/update/' + row.id,
            onSubmit : function() {
                return $(this).form('validate');
            },
            success : function(data) {
                $.messager.show({ // show error message
                    title : '提示',
                    msg : data,
                    timeout:2000
                });
                $('#dlg').dialog('close');
                $('#dt-grids').datagrid('reload');
            }
        });
    }



    $(function(){
        $('#dt-grids').datagrid({
            columns:[[
                    <#list list as m>
        {field:'${m.fieldname}',title:'${m.fielddesc}',width:100<#if m.data??>,data:${m.data},formatter: function(value){
            var data = this.data;
            for(var i=0,len=data.length;i<len;i++){
                if(value == data[i].id){
                    return data[i].text;
                }
            }
        }</#if>}<#if m_has_next>,</#if>
        </#list>
        ]]
    });
    });

</script>
<body>

<table id="dt-grids" class="easyui-datagrid"
       data-options="fit:true,singleSelect:true,rownumbers:true,onDblClickRow:editModel,pagination:true,toolbar:'#toolbar',url:'${ctx}/newPassword/query'">

</table>

<div id="toolbar">
    <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-edit',plain:true" onclick="editModel()">修改密码</a>
</div>
<div id="dlg" class="easyui-dialog" style="top:60%;left:60%;width: 330px; height: 250px;" data-options="closed:true,modal:true,buttons:'#dlg-buttons'">
    <div id='index_tabs' class="easyui-tabs" data-options="fit:true,border:false">
        <div title="基本信息">
            <form id="myform" method="post">
                <input type="hidden" name="id"/>
                <table cellpadding="0" cellspacing="0" class="form-table"
                       align='center'  data-options="fit:true,singleSelect:true,rownumbers:true,pagination:true,toolbar:'#toolbar',url:'${ctx}/newPassword/query'">

                    <tr>
                        <td style="width: 60px">新密码：</td>
                        <td style="width: 180px">
                            <input id="password" name="password" type="text" class="easyui-validatebox" data-options="validType:'maxLength[50]'"/>
                        </td>
                    </tr>
                </table>
            </form>
        </div>

    </div>
    <div id="dlg-buttons" style="text-align: center">
        <a href="#" class="easyui-linkbutton" iconCls="icon-save" onclick="saveModel()">保存</a>
        <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')">取消</a>
    </div>
</div>

</body>
</@layout>
